<?php

function linkAt($url, $args=array(), $append_get=false) {
  if($append_get) $params += $_GET;
  if(!$args) return $url;

  if(strpos($url,'?') === false) $url .= '?';
  elseif(!preg_match('/(\?|\&(amp;)?)$/',$url)) $url .= '&amp;';

  $param_arr = array();
  foreach( $args as $key=>$data) {
    if(is_array($data)) {
      foreach($value as $val) {
        $param_arr[] = htmlentities($key) . '[]=' . urlencode(utf8_decode($data));
      } 
    } else {
      $param_arr[] = htmlentities($key) . '=' . urlencode(utf8_decode($data));
    }
  }
  // doubles the O time I'm assuming to implode.
  $url .= implode('&amp;', $param_arr);

  return $url;
}

?>
